package com.imooc.ecommerce.converter;

import com.imooc.ecommerce.constant.BrandCategory;

import javax.persistence.AttributeConverter;

/**
 * <p>品牌分类枚举属性转换器
 *
 * @author Yaxi.Zhang
 * @since 2022/11/12 16:33
 */
public class BrandCategoryConverter implements AttributeConverter<BrandCategory, String> {

    @Override
    public String convertToDatabaseColumn(BrandCategory brandCategory) {
        return brandCategory.getCode();
    }

    @Override
    public BrandCategory convertToEntityAttribute(String code) {
        return BrandCategory.of(code);
    }

}
